<style>
{literal}
    .file_browse_input{
        position:relative;text-align: left;-moz-opacity:0 ;filter:alpha(opacity: 0);opacity: 0;z-index: 2;
        *position:inherit;*-moz-opacity:100 ;*filter:alpha(opacity: 100);*opacity:100;
    }
    .file_browse_fake{
        position:absolute;*position:inherit;top: 0px;left: 0px;z-index:1;*display:none;
    }

    .btn_delete_images{background:#3B5999; color:#FFFFFF; margin:10px 5px; font-weight:bold;padding:3px 15px 4px; font-family:verdana; font-size:11px; cursor: pointer; float:left; display:inline;}

    .btn_delete_images_hover{background:#ff6600; color:#FFFFFF; margin:10px 5px; font-weight:bold;padding:3px 15px 4px; font-family:verdana; font-size:11px; cursor: pointer; float:left; display:inline;}

{/literal}
</style>
{$TopMenu}
<div id="main_panel">
    <div style="background:#FFFFFF;display:none; position:absolute; border:2px solid #999" id="upload_new">
        <div class="header" style="padding:5px; font-size:14px"><div style="float:left; width:90%"><strong>Upload ảnh mới</strong></div><div style="float:right"><img src="style/images/i_close2.gif" width="13" height="13" class="boxClose" style="cursor:pointer; padding:2px" /></div><div style="clear:both"><span></span></div></div>
        <div style="height: expression( this.scrollHeight > 420 ? '420px' : 'auto' );overflow:auto; max-height:400px;">
            <div id="add_more">
            </div>
            <div id="origin_form">
                  {foreach from=$post_item_images item=image}
                <form class="upload_form" id="upload_form{$image.index}" name="upload_form{$image.index}"  lang="{$image.index}" enctype="multipart/form-data" method="post" action="">

                    <table cellpadding="1" border="0">
                        <tr>
                            <td width="4" align="center" valign="top">[{$image.index}]</td>
                            <td width="30" align="center" valign="top">
                                <img src="{$image.image_url}" style="border:1px solid #CCC" alt="" name="thumb_{$image.index}" width="60" height="60" id="thumb_{$image.index}"  title=""/>
                                <center style="color:#ccc;font-size:8px" id="real_name_{$image.index}">
                            {$image.real_name}
                                </center><div style="color:#FF0000;cursor:pointer;display:none;width:60px" id="cancel{$image.index}"><b>Hủy bỏ</b></div>	</td>
                            <td  align="left">
                                <div id="board{$image.index}">
                                    <table cellpadding="2" border="0" style="width:100%">
                                        <tr>
                                            <td align="left" valign="top">
                                                <strong>Chọn file ảnh <font style="color:#000; font-weight:bold;">(<font color="red">File: jpg, jpeg, gif, png <strong>&lt; 2MB</strong></font>)</font>:</strong>
                                                <div style="position: relative;*position:inherit">
                                                    <input type="file" size="45" class="file_browse_input browse_file" lang="{$image.index}" name="img_upload[{$image.index}]" id="img_upload{$image.index}"/>
                                                    <div class="file_browse_fake">
                                                        <input class="fake_input" readonly="readonly"  value="Chọn ảnh từ Máy tính"   id="fake_input{$image.index}" style="border:1px solid #CCCCCC;float:left;margin-top:2px;width:220px; background-color:#fff" /><img style="float:left;margin:0px;" src="style/images/button_chon_anh.gif" />
                                                    </div>
                                                </div>	</td>
                                            <td width="244" align="left" valign="top">
                                                <strong>Hoặc URL:</strong><br />
                                                <input type="text" value="{$image.url}" name="url[{$image.index}]" class="url_input" lang="{$image.index}" id="url{$image.index}" style="width:99%"/></td>
                                        </tr>
                                        <tr>
                                            <td align="left" valign="top">
                                                <strong>Mô tả cho ảnh: </strong><br />
                                                <input type="text" value="{$image.des}" name="des[{$image.index}]" id="des{$image.index}"   style="width:99%" maxlength="50"/></td>
                                            <td align="left" valign="top"><input type="submit" value="Tải lên" id="submit{$image.index}" style="cursor:pointer;width:49%;margin-top:12px;float:left;display:none"/>
                                              <!--<input type="button" style="cursor:pointer;width:49%;margin-top:12px" value="Tải thêm ảnh" id="add_more{$image.index}" onclick="add_upload();"/> --> <img id="loading{$image.index}" src="style/images/uploading.gif" style="margin-top:12px;float:left;margin-left:10px;display:none" />
                                                <input type="hidden" value="" name="src[{$image.index}]" id="src{$image.index}" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>      </td>
                        </tr>
                    </table>

                </form>

                    {/foreach}
            </div>
        </div>
    </div>

    <div style="background:#FFFFFF;display:none;position:absolute; border:2px solid #999" id="upload_update">
        <div class="header" style="padding:5px; font-size:14px"><strong>Cập nhật thông tin cho ảnh</strong><img src="style/images/i_close2.gif" width="13" height="13" class="boxUpdateClose" style="cursor:pointer; padding:2px;  position:absolute" /></div>
        <div style="height: expression( this.scrollHeight > 420 ? '420px' : 'auto' );overflow:auto; max-height:400px;">
            <form id="upload_update_form" name="upload_update_form" lang="" enctype="multipart/form-data" method="post" action="">
                <table cellpadding="1" border="0" style="width:600px;">
                    <tr>
                        <td width="30" align="center" valign="top">
                            <img src="" style="border:1px solid #CCC" alt="" name="thumb_update" width="60" height="60" id="thumb_update"  title=""/>
                            <center style="color:#ccc;font-size:8px" id="real_name_update"></center>
                            <img id="loading_update" src="style/images/uploading.gif" style="width:60px;display:none" />
                        </td>
                        <td  align="left">
                            <table cellpadding="2" border="0" style="width:100%">
                                <tr>
                                    <td align="left" valign="top">
                                        <strong>Chọn ảnh mới <font style="color:#000; font-weight:bold;">(<font color="red">File: jpg, jpeg, gif, png <strong>&lt; 2MB</strong></font>)</font>:</strong>
                                        <div style="position: relative;*position:inherit">
                                            <input type="file" size="45" class="file_browse_input" name="img_upload_update" id="img_upload_update"/>
                                            <div class="file_browse_fake">
                                                <input readonly="readonly"  value="Chọn ảnh từ Máy tính"   id="fake_input_update" style="border:1px solid #CCCCCC;float:left;margin-top:2px;width:220px; background-color:#fff" /><img style="float:left;margin:0px;" src="style/images/button_chon_anh.gif" />
                                            </div>
                                        </div>	</td>
                                    <td width="244" align="left" valign="top">
                                        <strong>Hoặc URL:</strong><br />
                                        <input type="text" value="" name="url_update" id="url_update" style="width:99%"/></td>
                                </tr>
                                <tr>
                                    <td align="left" valign="top">
                                        <strong>Mô tả cho ảnh: </strong><br />
                                        <input type="text" value="" name="des_update" id="des_update"   style="width:99%" maxlength="50"/></td>
                                    <td align="left" valign="top"><input type="submit" value="Cập  nhật" style="cursor:pointer;width:49%;margin-top:12px;float:left"/> <input type="button" style="cursor:pointer;width:49%;margin-top:12px;margin-left:2px;float:left" id="cancel_update" value='Nhập lại'/>

                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div class="gallery_top" style="margin-top:5px">
        <div align="left">
            {$begin_form}
            <div class="navigation_gallery">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td style="color:#000000">Tìm ảnh: <input name="keywords" class="gallery_input" id="keywords" value="{$keywords}"/></td>
                        <td align="left" nowrap>
                            <select name="year" id="year" >{$option_year}</select>
                            <select name="month" id="month">{$option_month}</select>
                            <select name="day" id="day">{$option_day}</select>
                        </td>
                     </tr>
                     <tr>
                        <td align="right" colspan="2" style="padding:0 38px 5px 0;">
                            <input type="submit" id="btn_search_gallery" class="btn_search_gallery" value="Tìm ảnh" title="Tìm ảnh" style="cursor:pointer"/>
                        </td>
                    </tr>
                </table>


            </div>




                   {if $gallery_user_id}
            <div><input type="hidden" name="user_id" id="user_id"  value="{$gallery_user_id}" /></div>
                   {/if}
                  {$end_form}     
        </div>
        <div id="buttonUpload" class="btn_upload_gallery" align="center" style="float:left">UP ẢNH MỚI</div>
        <div class="btn_delete_images" align="center" style="float:left;">XÓA NHIỀU ẢNH</div>
        <div align="center" class="btn_upload_gallery" onmouseover="this.className='btn_upload_gallery_hover'" onmouseout="this.className='btn_upload_gallery'" onclick="{literal}window.location=url_y+'&year='+getValueId('year');{/literal}" style="float:right" >
            Load lại
        </div>
        <div style="clear:both; display:none"></div>
    </div>

    <div style=" clear:both">

        <div id="personal_gallery">
            <div id="new_img_uploaded"></div>
    {if $items}

    {foreach from=$items item=items name=itemImage}
            <div  class="gallery_list_img" align="center" id="list_gallery_images{$items.id}">
                <div>
                    <div align="center" class="box_img" style="position:relative;">
                        <div style="position: absolute;top:0; left: 0">
                            <input type="checkbox" id="checkImage_{$smarty.foreach.itemImage.index}" name="checkImage" value="{$items.id}">
                        </div>
                        <a class="img_thumb" id="href_{$items.id}"  href="{$items.im_link}" lang="{$items.direct_link}" style="display:block">
                            <img  id="preview_image{$items.id}" title="Xem ảnh" alt="{$items.des}" src="{$items.original_image_url}" width="100" height="100"/>
                        </a>
                    </div>
                    <div align="left" style="padding:5px;height:24px;overflow:hidden;color:#999" title="{$items.des}" id="des{$items.id}">{$items.des}</div>
                </div>

                <div class="gallery_content_img">
                    <a onclick="del_images({$items.id});" href="javascript:void(0);">
                        Xóa</a> | <a href="javascript:void(0);" onclick="show_update({$items.id});">Sửa</a>  | <a href="{$items.direct_link}" target="_blank">Ảnh gốc</a> <br />
                    (<font color="green">
            {$items.time}</font>)
                </div>




            </div>
    {/foreach}
    {else}
            <div style="padding:10px" id="div_no_images" align="center">
                <strong>Chưa có ảnh nào cả! Bạn hãy thử tìm lại với điều kiện khác ( từ khoá, ngày, tháng...) hoặc Upload ảnh mới vào thư viện ảnh cá nhân của bạn!</strong>
            </div>
    {/if}
            <div style="clear:left"><span></span></div>
        </div>
        <div class="btn_delete_images" align="center" style="float:left;margin:0 5px;">XÓA NHIỀU ẢNH</div>
{if $paging}
        <div>
            <div align="right" style="height:33px;">
                <div style="float:right; margin:0 10px 10px 0px">
                {$paging}
                </div>
            </div>
        </div>
{/if}
    </div>
</div>
<script language="javascript">
var url_y="{$url_y}";
var url_m="{$url_m}";
var url_d="{$url_d}";

//For Upload:
var more_id		={$more_id};
var no_img		='{$no_image_url}';
var image_path	='{$image_path}';
var img_server	={$img_server};
var user_id		='{$user_id}';
var index_current='1';
var max_upload	={$max_upload};
{literal}
jQuery(document).ready(function(){
        jQuery("#year").change(function() {
                window.location=url_y+"&year="+getValueId('year');
        });
        jQuery("#month").change(function() {
                window.location=url_m+"&month="+getValueId('month');
        });
        jQuery("#month").change(function() {
                window.location=url_m+"&month="+getValueId('month');
        });
        jQuery("#day").change(function() {
                window.location=url_d+"&day="+getValueId('day');
        });
        jQuery(".img_info").livequery('click',function (){
                this.select();
        });
        jQuery(".info_add").livequery('click',function (){
                var display=jQuery("#info_add"+this.lang).css("display");
                jQuery(".more_info_img").css("display","none");
                if(display=='none')jQuery("#info_add"+this.lang).toggle();
        });
        check_all_perform();

        jQuery('.btn_delete_images').hover(function(){
            jQuery(this).removeClass('btn_delete_images').addClass('btn_delete_images_hover');
        },function(){
            jQuery(this).removeClass('btn_delete_images_hover').addClass('btn_delete_images');
        });

        jQuery('.btn_delete_images').click(function(){
            //var delIDs = new Array();
            var lstIDs = '';
            var checkVals = jQuery('input[name=checkImage]').serializeArray();
            jQuery.each(checkVals, function(i,check){
                //delIDs[i] = jQuery(check).val();
                lstIDs += lstIDs ? ',' : '';
                lstIDs += jQuery(check).val();
            });

            //len = delIDs.length;
            if(lstIDs)
            {
                if(!confirm('Bạn có chắc muốn xóa những ảnh này không?\nViệc này có thể làm mất ảnh trong các sản phẩm liên quan!'))
                    return false;
                else{


                    jQuery.ajax({
                            url:WEB_DIR+'ajax.php?act=upload&code=gallery_bulk_delete',
                            data:{ids: lstIDs},
                            success: function(html){
                                if(html=='success'){
                                    window.location.href = window.location.href;
                                   /*for(var i= 0; i < len; i++)
                                   {
                                        jQuery("#list_gallery_images"+delIDs[i]).hide().html('');
                                   }
                                   jQuery('.img_thumb').lightBox();*/
                                }
                                else if(html=='fail'){
                                        alert('Không xoá được ảnh!');
                                }
                                else{
                                        alert(html);
                                }
                           }
                    });
                }
            }
            else
            {
                alert('Hãy chọn các ảnh cần xóa!');
            }
        });
});
{/literal}
</script>